import java.util.Arrays;

public class Test1 {
    public static void main(String[] args) {

    }
    public int findTheLongestBalancedSubstring(String s) {
        int sum = 0 ;
        for(int i = 0 ; i< s.length() ; i ++){
            int a = 0 ;
            int b = 0 ;
            int last = i ;
            if(s.charAt(last) != '1'){
                while(last<s.length() && s.charAt(last)!= '1'){
                    a ++ ;
                    last ++ ;
                }
                while(last<s.length() && s.charAt(last)!='0'){
                    b ++ ;
                    last ++ ;
                    if(a == b){
                        break ;
                    }
                }
                if(a == b){
                    sum = sum < (a+b)?(a+b): sum ;
                }

            }
        }
        return sum ;
    }

    public String longestCommonPrefix (String[] strs) {
        // write code here
        Arrays.sort(strs) ;
        StringBuffer strbuf = new StringBuffer() ;
      if(strs.length > 0){
          int len = strs[0].length() ;
          for(int i = 0 ; i < len ; i ++){
              for(int j = 1 ;j < strs.length ; j++ ){
                  if(strs[0].charAt(i) != strs[j].charAt(i)){
                      return strbuf.toString() ;
                  }
              }
              strbuf.append(strs[0].charAt(i)) ;
          }
      }

        return strbuf.toString() ;

    }

}
